/* jshint indent: 2 */
module.exports = (app) => {
  const sequelize = app.model;
  const DataTypes = app.Sequelize.DataTypes;
  const Attention = sequelize.define('attention', {
    id: {
      type: DataTypes.INTEGER(11),
      allowNull: false,
      primaryKey: true,
      autoIncrement: true,
    },
  }, {
    createdAt: 'create_time', // 记录创建时间
    updatedAt: 'update_time', // 记录更新时间
    freezeTableName: true, // 不允许修改表名
  });

  Attention.associate = () => {
    app.model.Attention.belongsTo(app.model.User, {
      as: 'from',
      foreignKey: 'fromId',
    });
    app.model.Attention.belongsTo(app.model.User, {
      as: 'to',
      foreignKey: 'toId',
    });
  };
  return Attention;
};
